package com.example.borui.partpositionproject.simple.partposition.five;

import android.content.Context;
import android.support.v7.widget.RecyclerView;

import com.example.borui.partpositionproject.partpisition.base.BaseClusterPartPosition;
import com.example.borui.partpositionproject.partpisition.base.BasePartPosition;
import com.example.borui.partpositionproject.partpisition.base.IPartPositionView;
import com.example.borui.partpositionproject.partpisition.view.IPartPositionBean;
import com.example.borui.partpositionproject.simple.bean.DataBean;
import com.example.borui.partpositionproject.simple.factory.PartPositionFactory;
import com.example.borui.partpositionproject.simple.partposition.four.FourPartPosition;
import com.example.borui.partpositionproject.simple.partposition.one.OnePartPosition;
import com.example.borui.partpositionproject.simple.partposition.three.ThreePartPosition;
import com.example.borui.partpositionproject.simple.partposition.two.TwoPartPosition;

/**
 * Created by borui on 2017/9/29.
 */

public class FivePartPosition extends BaseClusterPartPosition<DataBean> {

    private IPartPositionView view;

    public FivePartPosition(Context mContext, int type, int position, IPartPositionView view) {
        super(mContext, type, position, view);
        this.view = view;
    }

    @Override
    public BasePartPosition buildProcessor(int position, IPartPositionBean bean) {
        return PartPositionFactory.builtBasePartPosition(getContext(), position, bean, view);
    }

    @Override
    public void onBindPartPosition(BasePartPosition basePartPosition, int partPosition, int position) {
        BasePartPosition lastPartPosition = getPartPistionAdapterHelper().getLastProcessor();
        if(basePartPosition instanceof TwoPartPosition && basePartPosition != lastPartPosition){
            TwoPartPosition twoPartPosition = (TwoPartPosition) basePartPosition;
            twoPartPosition.setHasDivider(false);
//            if(null != getPartPistionAdapterHelper()){
//                BasePartPosition lasePartPosition = getPartPistionAdapterHelper().getProcessor(partPosition - 1);
//                if(null != lasePartPosition && lasePartPosition instanceof OnePartPosition){
//                    TwoPartPosition twoPartPosition = (TwoPartPosition) basePartPosition;
//                    twoPartPosition.setHasDivider(false);
//                }
//            }
        }

        if(basePartPosition instanceof OnePartPosition && basePartPosition != lastPartPosition){
            OnePartPosition twoPartPosition = (OnePartPosition) basePartPosition;
            twoPartPosition.setHasDivider(false);
        }

        if(basePartPosition instanceof ThreePartPosition && basePartPosition != lastPartPosition){
            ThreePartPosition twoPartPosition = (ThreePartPosition) basePartPosition;
            twoPartPosition.setHasDivider(false);
        }

        if(basePartPosition instanceof FourPartPosition && basePartPosition != lastPartPosition){
            FourPartPosition twoPartPosition = (FourPartPosition) basePartPosition;
            twoPartPosition.setHasDivider(false);
        }
    }

    @Override
    public String logName() {
        return "FivePartPosition";
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
    }
}
